package XML.g3.aufgabe2;

import java.io.File;

import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import org.xml.sax.SAXException;


public class ValidateParty {
	
	public static void main(String[] args) throws JAXBException, SAXException {
		File file = new File("partyGen.xml");
		JAXBContext context = JAXBContext.newInstance(Party.class);
		Unmarshaller unmarshaller = context.createUnmarshaller();
		SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
		Schema schema = sf.newSchema(new File("party.xsd"));
		unmarshaller.setSchema(schema);
		
		Party party = (Party) unmarshaller.unmarshal(file);
		System.out.println(party.getGaeste().get(1).getGetraenke().get(0));
	}
	
}
